package com.xuetang9.t9.xinhuaxia.controller;

import com.xuetang9.t9.xinhuaxia.beans.FirstCategory;
import com.xuetang9.t9.xinhuaxia.beans.SecondCategory;
import com.xuetang9.t9.xinhuaxia.service.ISecondCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 李亚奇
 * @version 1.0
 * @desc TODO
 * @date 2020/3/3 14:16
 * @copyright liyq
 * @address 成都西部国际金融中心2栋2201
 **/
@RestController
@RequestMapping("secondcategory")
public class SecondCategoryController {
    @Autowired
    private ISecondCategoryService secondCategoryService;

    @PostMapping("save")
    public boolean insert(@RequestBody SecondCategory secondCategory){
        boolean insert = secondCategoryService.insert(secondCategory);
        return insert;
    }
    @GetMapping("remove/{id}")
    public boolean remove(@PathVariable(value = "id",required = false) Long id){
        boolean remove = secondCategoryService.remove(id);
        return remove;
    }
    @PostMapping("update")
    public boolean update(@RequestBody SecondCategory secondCategory){
        boolean update = secondCategoryService.update(secondCategory);
        return update;
    }

    @GetMapping("list")
    public List<SecondCategory> queryAll(){
        List<SecondCategory> secondCategories = secondCategoryService.queryAll();
        return secondCategories;
    }
}
